package util;

import java.lang.reflect.Field;
import java.util.Map;

import entities.Domain;

public class ObjectDebug {
	public static void debug(Object obj) {
		try {
			System.out
					.println("-------------------------------------------------------------");
			for (Field f : obj.getClass().getDeclaredFields()) {
				f.setAccessible(true);
				System.out.print(f.getName());
				System.out.print(": ");
				System.out.print(f.get(obj));
				System.out.println("");
			}
			System.out
					.println("-------------------------------------------------------------");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void debugLanguage(Domain obj) {
		try {
			System.out
					.println("======================DEBUG=========================");
			System.out.println("Server Language : " + obj.getServerLanguage());
			System.out.println("Server OS : " + obj.getServerOs());
			System.out.println("WebServer : " + obj.getWebServer());
			System.out.println("Server IP : " + obj.getIp());
			System.out.println("Dig Result : " + obj.getDig());
			System.out.println("Whois Result : ");
			System.out.println("--------");
			System.out.println(obj.getWhois().length());
			System.out.println("--------");
			System.out.println("Issue Date : " + obj.getCreatedDate());
			System.out.println("Update Date : " + obj.getUpdatedDate());
			System.out.println("Expired Date : " + obj.getExpiredDate());
			System.out.println("WebServer OrgName : "
					+ obj.getWebServerOrgName());
			System.out.println("WebServer Address : "
					+ obj.getWebServerAddress());
			System.out.println("WebServer City : " + obj.getWebServerCity());
			System.out.println("WebServer Country : "
					+ obj.getWebServerCountry());
			System.out.println("CDN Server : " + obj.getCdnServer());
			System.out.println("Email : " + obj.getEmail());
			System.out.println("Server Email : " + obj.getServerEmail());
			System.out.println("Last Update : " + obj.getLastUpdate());
			System.out
					.println("======================END OF DEBUG=========================");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void debugMap(Map<String, Object> obj) {
		try {
			System.out
					.println("-------------------------------------------------------------");

			for (Map.Entry<String, Object> m : obj.entrySet()) {
				System.out.print(m.getKey());
				System.out.print(": ");
				System.out.println(m.getValue());
			}

			System.out
					.println("-------------------------------------------------------------");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
